package cn.tedu.review;

import org.junit.jupiter.api.Test;

public class ReviewOOP2 {
    @Test
    public void test() {
        new Cat();
        Cat cat = new Cat("散财童子", 12, 1009);
        DD dd = new DD();
        dd.eat();
    }
}

class Cat {
    static {
        System.out.println("我是静态代码块");
    }

    String name;
    int id;
    double price;

    {
        System.out.println("我是构造代码块");
    }

    public Cat() {
        System.out.println("我是无参构造器");
    }

    public Cat(String name, int id, double price) {
        this.name = name;
        this.id = id;
        this.price = price;
    }

    private void play() {
        System.out.println("玩啥都行");
    }

    public void eat() {
        {
            System.out.println("我是局部代码块，用于控制变量范围，越小越好");
        }
    }
}

class DD extends Cat {
    String name;

    public DD() {
        super("12", 12, 12);
    }

    @Override
    public void eat() {
        System.out.println(super.name);
        System.out.println("爱吃小鱼干");

    }
static {
        /*静态不能使用super this*/
       // this.name="";
}
    public void play() {
        System.out.println(112);
    }
}
